myApp.controller('AppCtrl', function($scope,  $localStorage, $window,$state,toaster,$serAccessSignin) {
        // 如果为IE则给body添加`ie`css类，如果为移动设备添加`smart`css类
        var isIE = !!navigator.userAgent.match(/MSIE/i);
        if(isIE){ angular.element($window.document.body).addClass('ie');}
        if(isSmartDevice( $window ) ){ angular.element($window.document.body).addClass('smart')}

        // 配置
        $scope.app = {
            name: 'Maybe',
            version: '1.0.01',
            color: {
                primary: '#7266ba',
                info:    '#23b7e5',
                success: '#27c24c',
                warning: '#fad733',
                danger:  '#f05050',
                light:   '#e8eff0',
                dark:    '#3a3f51',
                black:   '#1c2b36'
            },
            settings: {
                themeID: 1,
                navbarHeaderColor: 'bg-black',
                navbarCollapseColor: 'bg-white-only',
                asideColor: 'bg-black',
                headerFixed: true,
                asideFixed: false,
                asideFolded: false,
                asideDock: false,
                container: false
            }
        };

        // 保存设置为本地存储
        if ( angular.isDefined($localStorage.settings) ) {
            $scope.app.settings = $localStorage.settings;
        } else {
            $localStorage.settings = $scope.app.settings;
        }
        $scope.$watch('app.settings', function(){
            if( $scope.app.settings.asideDock  &&  $scope.app.settings.asideFixed ){
                // aside dock and fixed must set the header fixed.
                $scope.app.settings.headerFixed = true;
            }
            // for box layout, add background image
            $scope.app.settings.container ? angular.element('html').addClass('bg') : angular.element('html').removeClass('bg');
            // save to local storage
            $localStorage.settings = $scope.app.settings;
        }, true);

        function isSmartDevice( $window ) {
            // Adapted from http://www.detectmobilebrowsers.com
            var ua = $window['navigator']['userAgent'] || $window['navigator']['vendor'] || $window['opera'];
            // Checks for iOs, Android, Blackberry, Opera Mini, and Windows mobile devices
            return (/iPhone|iPod|iPad|Silk|Android|BlackBerry|Opera Mini|IEMobile/).test(ua);
        }

        $scope.checkOut = function(){
            $serAccessSignin.logOut({

            }).then(function(res){
                if(res.code==1){
                    toaster.success('提示',res.message);
                    $state.go('access.signin');
                }else{
                    toaster.info('提示',res.message);
                    $state.go('access.signin');
                }
            })
        }
    });